home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jdoc_cmds.tcl < prev    next >
Encoding:
Text File  |  1995-03-14  |  6.3 KB  |  211 lines

  1. # jdoc_cmds.tcl - command procedures for jdoc
  2. # Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non-profit, noncommercial use.
  5.  
  6. ##############################################################################
  7. # jdoc:cmd:about - make the about box
  8. ##############################################################################
  9.  
  10. proc jdoc:cmd:about {} {
  11.   global VERSION
  12.   set about_help [format {
  13.     j:rt:hl "jdoc"
  14.     j:rt:cr
  15.     j:rt:rm "by Jay Sekora, "
  16.     j:rt:tt "js@bu.edu"
  17.     j:rt:par
  18.     j:rt:rm "An X Windows application for viewing help files."
  19.     j:rt:cr
  20.     j:rt:rm "Version %s."
  21.     j:rt:par
  22.     j:rt:rm "Copyright \251 1992-1994 by Jay Sekora.  "
  23.     j:rt:rm "All rights reserved, except that this file may be freely "
  24.     j:rt:rm "redistributed in whole or in part for non\255profit, "
  25.     j:rt:rm "noncommercial use."
  26.     j:rt:par
  27.     j:rt:rm "If you find bugs or have suggestions for improvement, "
  28.     j:rt:rm "please let me know.  "
  29.     j:rt:rm "Feel free to use bits of this code in your own "
  30.     j:rt:tt "wish"
  31.     j:rt:rm " scripts."
  32.   } $VERSION]
  33.   j:about .about $about_help
  34.   j:about:button .about {About jdoc} $about_help
  35.   j:about:button .about {About the Author} [j:about_jay]
  36.   j:about:button .about {About Tk and Tcl} [j:about_tktcl]
  37.   
  38.   tkwait window .about
  39. }
  40.  
  41. ##############################################################################
  42. # jdoc:cmd:help - get help on jdoc
  43. ##############################################################################
  44.  
  45. proc jdoc:cmd:help {} {
  46.   exec jdoc jdoc &
  47. }
  48.  
  49. ##############################################################################
  50. # jdoc:cmd:doc_prefs - preferences panel
  51. ##############################################################################
  52.  
  53. proc jdoc:cmd:doc_prefs {} {
  54.   global JDOC_PREFS
  55.   
  56.   set w .doc_prefs
  57.   toplevel $w
  58.   wm title $w "Help Viewer Preferences"
  59.  
  60.   frame $w.size
  61.   label $w.size.wl -text {Width:}
  62.   entry $w.size.we -relief sunken -width 3 \
  63.     -textvariable JDOC_PREFS(textwidth)
  64.   label $w.size.hl -text {Height:}
  65.   entry $w.size.he -relief sunken -width 3 \
  66.     -textvariable JDOC_PREFS(textheight)
  67.  
  68.   j:colour_chooser $w.textbg -variable JDOC_PREFS(textbg) \
  69.     -label "Normal Background:"
  70.   j:colour_chooser $w.textfg -variable JDOC_PREFS(textfg) \
  71.     -label "Normal Foreground:"
  72.   j:colour_chooser $w.textsb -variable JDOC_PREFS(textsb) \
  73.     -label "Selected Background:"
  74.   j:colour_chooser $w.textsf -variable JDOC_PREFS(textsf) \
  75.     -label "Selected Foreground:"
  76.   
  77.   label $w.textsbw-label -text "Selection Border Width:" -anchor w
  78.   scale $w.textsbw -from 0 -to 25  -orient horizontal \
  79.     -command {set JDOC_PREFS(textsbw)}
  80.   $w.textsbw set $JDOC_PREFS(textsbw)
  81.   
  82.   label $w.textbw-label -text "Text Border Width:" -anchor w
  83.   scale $w.textbw -from 0 -to 50  -orient horizontal \
  84.     -command {set JDOC_PREFS(textbw)}
  85.   $w.textbw set $JDOC_PREFS(textbw)
  86.   
  87.   j:buttonbar $w.b -default save -buttons [format {
  88.     { 
  89.       save Save {
  90.         jdoc:configure_text .t
  91.         j:write_prefs -array JDOC_PREFS -file jdoc-defaults
  92.         destroy %s
  93.       }
  94.     } {
  95.       done Done {
  96.         jdoc:configure_text .t
  97.         destroy %s
  98.       }
  99.     }
  100.   } $w $w]
  101.   
  102.   pack $w.size.wl $w.size.we [j:filler $w.size] $w.size.hl $w.size.he \
  103.     -in $w.size -side left
  104.  
  105.   pack \
  106.     $w.size \
  107.     [j:rule $w] \
  108.     $w.textbg \
  109.     [j:rule $w] \
  110.     $w.textfg \
  111.     [j:rule $w] \
  112.     $w.textsb \
  113.     [j:rule $w] \
  114.     $w.textsf \
  115.     [j:rule $w] \
  116.     $w.textsbw-label $w.textsbw \
  117.     [j:filler $w] \
  118.     $w.textbw-label $w.textbw \
  119.     [j:rule $w] \
  120.     $w.b \
  121.     -in $w -side top -fill x
  122.  
  123.   j:dialogue $w        ;# position in centre of screen
  124.  
  125.   focus $w
  126.   j:default_button $w.b.save $w.size.we $w.size.he $w
  127.   j:tab_ring $w.size.we $w.size.he
  128.   bind $w <Key-Tab> "focus $w.size.we"
  129. }
  130.  
  131. ##############################################################################
  132. # jdoc:cmd:quit - quit
  133. ##############################################################################
  134.  
  135. ### THIS CURRENTLY ISN'T USED
  136.  
  137. proc jdoc:cmd:quit {} {
  138.   if [j:confirm -text "Are you sure you want to quit?"] {
  139.     exit 0
  140.   }
  141. }
  142.  
  143. ##############################################################################
  144. # jdoc:cmd:load - prompt user to select topic from a list
  145. ##############################################################################
  146.  
  147. proc jdoc:cmd:load {} {
  148.   global JDOC_PREFS JDOC_PATH JDOC_TOPIC
  149.   
  150.   if [winfo exists .topics] {destroy .topics}
  151.   toplevel .topics
  152.   label .topics.l -text "Double\255click on a topic:"
  153.   listbox .topics.lb -relief flat \
  154.     -yscroll {.topics.sb set} -exportselection false
  155.   j:tk3 {.topics.lb configure -geometry 30x20}
  156.   j:tk4 {.topics.lb configure -width 30 -height 20}
  157.   scrollbar .topics.sb -command {.topics.lb yview}
  158.   button .topics.ok -width 10 -text OK -command {
  159.     set JDOC_TOPIC [.topics.lb get [lindex [.topics.lb curselection] 0]]
  160.     destroy .topics
  161.   }
  162.   pack append .topics \
  163.     .topics.ok {bottom pady 5 padx 5} \
  164.     [j:rule .topics] {bottom fillx} \
  165.     .topics.l {top fillx pady 10} \
  166.     [j:rule .topics] {top fillx} \
  167.     .topics.lb {left expand fill} \
  168.     [j:rule .topics] {left filly} \
  169.     .topics.sb {left filly}
  170.  
  171.   set topics {}
  172.   
  173.   foreach dir $JDOC_PATH {
  174.     foreach file [glob -nocomplain $dir/*.jdoc] {
  175.       set topic [file rootname [file tail $file]]
  176.       if {[lsearch -exact $topics $topic] == -1} {
  177.         lappend topics $topic
  178.       }
  179.     }
  180.   }
  181.   if {"x$topics" == "x"} {
  182.     j:alert -text "Unable to find any help files."
  183.     destroy .topics
  184.     return
  185.   }
  186.   foreach topic [lsort $topics] {
  187.     .topics.lb insert end $topic
  188.   }
  189.   bind .topics.lb <Double-Button-1> {
  190.     set JDOC_TOPIC [.topics.lb get [lindex [.topics.lb curselection] 0]]
  191.     destroy .topics
  192.   }
  193.   bind .topics.lb <Button-3> [bind .topics.lb <Double-Button-1>]
  194.   j:dialogue .topics
  195.   tkwait window .topics
  196.   jdoc:load_topic $JDOC_TOPIC
  197. }
  198.  
  199. ######################################################################
  200. # jdoc:cmd:print_postscript - print rich-text as postscript using lpr
  201. ######################################################################
  202.  
  203. proc jdoc:cmd:print_postscript {} {
  204.   global J_PREFS
  205.   if [j:confirm -priority 24 \
  206.     -text "Print as PostScript using `lpr' to printer `$J_PREFS(printer)'?"] {
  207.     exec lpr -P$J_PREFS(printer) << [j:tc:ps:convert_text .t]
  208.   }
  209. }
  210.